/* Contains all Javascript coding for Kukui Kup mock-up display billboard */
google.load('visualization', '1', {packages:['table']});
google.setOnLoadCallback(drawVisualizations);

/* Calls all the methods that draw a visualization on the page */
function drawVisualizations() {
  drawConsumptionStand();
  drawKNuts();
  drawTopKPeople();
  drawLatestActions();
}

/* Draws mock-up data for Latest Actions */
function drawLatestActions() {
	var data = new google.visualization.DataTable();
	data.addColumn('string', '');
	data.addColumn('string', 'Action');
	data.addRows(3);
	
	data.setCell(0, 0, 'Patty B');
	data.setCell(0, 1, 'Turn off lights (commitment)');
	
	data.setCell(1, 0, 'Kim K');
	data.setCell(1, 1, 'Energy Apocolypse');
	
	data.setCell(2, 0, 'Floor 5');
	data.setCell(2, 1, 'Reduce energy by 5% (goal)');
	
	var table = new google.visualization.Table(document.getElementById('latestActions'));
    table.draw(data, {allowHTML: true});
}

/* Draws mock-up data for Top Kukui Nut Individuals */
function drawTopKPeople() {
	var data = new google.visualization.DataTable();
	data.addColumn('string', '');
	data.addColumn('string', 'Resident');
	data.addColumn('string', 'Floor');
	data.addColumn('number', 'K-Nuts');
	data.addRows(3);
	
	data.setCell(0, 0, '', '<img src="face.jpg"></img>');
	data.setCell(0, 1, 'Jim K');
	data.setCell(0, 2, '7');
	data.setCell(0, 3, 120);
	
	data.setCell(1, 0, '', '<img src="face.jpg"></img>');
	data.setCell(1, 1, 'Maile K');
	data.setCell(1, 2, '4');
	data.setCell(1, 3, 110);
	
	data.setCell(2, 0, '', '<img src="face.jpg"></img>');
	data.setCell(2, 1, 'John H');
	data.setCell(2, 2, '2');
	data.setCell(2, 3, 105);
	
	var table = new google.visualization.Table(document.getElementById('kIndividuals'));
    table.draw(data, {allowHtml: true});
}

/* Draws mock-up data for energy consumption by floors */
function drawConsumptionStand() {
  var data = new google.visualization.DataTable();
  data.addColumn('string', 'Floor');
  data.addColumn('number', 'kWh');
  data.addRows(13);
  data.setCell(0, 0, '1');
  data.setCell(1, 0, '2');
  data.setCell(2, 0, '3');
  data.setCell(3, 0, '4');
  data.setCell(4, 0, '5');
  data.setCell(5, 0, '6');
  data.setCell(6, 0, '7');
  data.setCell(7, 0, '8');
  data.setCell(8, 0, '9');
  data.setCell(9, 0, '10');
  data.setCell(10, 0, '11');
  data.setCell(11, 0, '12');
  data.setCell(12, 0, '13');
  data.setCell(0, 1, 1756);
  data.setCell(1, 1, 1237);
  data.setCell(2, 1, 1856);
  data.setCell(3, 1, 1346);
  data.setCell(4, 1, 1876);
  data.setCell(5, 1, 1902);
  data.setCell(6, 1, 1349);
  data.setCell(7, 1, 1576);
  data.setCell(8, 1, 1689);
  data.setCell(9, 1, 1922);
  data.setCell(10, 1, 1946);
  data.setCell(11, 1, 2011);
  data.setCell(12, 1, 1853);
  
  var table = new google.visualization.Table(document.getElementById('consumptionStand'));
  table.draw(data, {allowHTML: true});
}

/* Draws mock-up data for K-Nuts for each floor */
function drawKNuts() {
  var data = new google.visualization.DataTable();
  data.addColumn('string', 'Floor');
  data.addColumn('number', 'K-Nuts');
  data.addRows(13);
  data.setCell(0, 0, '1');
  data.setCell(1, 0, '2');
  data.setCell(2, 0, '3');
  data.setCell(3, 0, '4');
  data.setCell(4, 0, '5');
  data.setCell(5, 0, '6');
  data.setCell(6, 0, '7');
  data.setCell(7, 0, '8');
  data.setCell(8, 0, '9');
  data.setCell(9, 0, '10');
  data.setCell(10, 0, '11');
  data.setCell(11, 0, '12');
  data.setCell(12, 0, '13');
  data.setCell(0, 1, 615);
  data.setCell(1, 1, 623);
  data.setCell(2, 1, 544);
  data.setCell(3, 1, 660);
  data.setCell(4, 1, 475);
  data.setCell(5, 1, 525);
  data.setCell(6, 1, 675);
  data.setCell(7, 1, 622);
  data.setCell(8, 1, 550);
  data.setCell(9, 1, 322);
  data.setCell(10, 1, 300);
  data.setCell(11, 1, 125);
  data.setCell(12, 1, 300);
  
  var table = new google.visualization.Table(document.getElementById('kNuts'));
  table.draw(data, {allowHTML: true});
}

/* Writes the current date on the document
 * e.x. Monday, October 10, 2010
 */
function printDateNow() {
  var now = new Date();
  var weekday = new Array(7);
  weekday[0]="Sunday";
  weekday[1]="Monday";
  weekday[2]="Tuesday";
  weekday[3]="Wednesday";
  weekday[4]="Thursday";
  weekday[5]="Friday";
  weekday[6]="Saturday";
  
  var month = new Array(12);
  month[0]="January";
  month[1]="February";
  month[2]="March";
  month[3]="April";
  month[4]="May";
  month[5]="June";
  month[6]="July";
  month[7]="August";
  month[8]="September";
  month[9]="October";
  month[10]="November";
  month[11]="December";
  document.write(weekday[now.getDay()] + ", " + month[now.getMonth()] 
				 + " " + now.getDate() + ", " + now.getFullYear());
}

